home *** CD-ROM | disk | FTP | other *** search
- ## ftp_master_test.tab
- # Perform many FTP functions while handling exceptions.
- # Basically, this script does recursive Get, Put, and Delete as well as Rename and Test.
- # script assumes:
- # 1. There is a temp/foo directory on the remote server
- # 2. There is a temp/foo/test_file.dat file on the remote server
- # 3. There is a c:\temp\foo local directory (tree) filled with all the files and directories
- # you wish to move back and forth.
- # 4. the environment variables: USER.SERVER, USER.USERID, and USER.PASSWORD are set elsewhere,
- # perhaps in the global (computer) environment or the local environment of WinCron via
- # Config.tg or AutoRun.tg. You could also set them here in this this script or hard-code the
- # values passed to -ftp connect.
- {
- -name ftp_master_test
- -start
- -stop
-
- # tell user what we are about to do
- -action -print ftp master test
-
- # setup local environment
- -action -set LOCAL_DIR=c:\temp\foo
-
- # I set these in my global environment, you can set them here
- #-action -set USER.SERVER=xxx
- #-action -set USER.USERID=yyy
- #-action -set USER.PASSWORD=zzz
-
- # CONNECT TO FTP SERVER
- -action -print connecting to remote ftp server
- -action -onerror connect_fail
- -action -ftp connect handle %USER.SERVER% 21 %USER.USERID% %USER.PASSWORD%
-
- # DEBUG
- #-action -print lastline: %FTP.LASTLINE%
-
- # TEST FOR "test-file" ON REMOTE SERVER
- -action -print testing for "test-file" on remote ftp server
- -action -set OPERATION=test1
- -action -onerror general_failure
- -action -ftp test handle temp/foo/test_file.dat
-
- # DEBUG
- #-action -print lastline: %FTP.LASTLINE%
-
- # GET A FILE FROM REMOTE SERVER
- -action -print getting file from remote ftp server
- -action -set OPERATION=get
- -action -onerror general_failure
- -action -ftp get handle temp/foo/test_file.dat %LOCAL_DIR%\test_file.dat 0
-
- # DEBUG
- #-action -popup Did we get test_file.dat to %LOCAL_DIR%\test_file.dat?
- #-action -print lastline: %FTP.LASTLINE%
-
- # DELETE THE test-file FROM REMOTE SERVER
- -action -print deleting the file from remote ftp server
- -action -set OPERATION=del
- -action -onerror general_failure
- -action -ftp del handle temp/foo/test_file.dat
-
- # DEBUG
- #-action -popup Has temp/foo/test_file.dat been deleted?
- #-action -print lastline: %FTP.LASTLINE%
-
- # PUT A FILE ON REMOTE SERVER
- -action -print putting file back on remote ftp server
- -action -set OPERATION=put
- -action -onerror general_failure
- -action -ftp put handle %LOCAL_DIR%\test_file.dat temp/foo/test_file.dat 0
-
- # DEBUG
- #-action -popup Is temp/foo/test_file.dat back again?
- #-action -print lastline: %FTP.LASTLINE%
-
- # TEST FOR "test-file" ON REMOTE SERVER
- -action -print testing for "test-file" on remote ftp server
- -action -set OPERATION=test2
- -action -onerror general_failure
- -action -ftp test handle temp/foo/test_file.dat
-
- # DEBUG
- #-action -print lastline: %FTP.LASTLINE%
-
- # RENAME "test-file" ON REMOTE SERVER
- -action -print rename the test-file on remote ftp server
- -action -set OPERATION=rename
- -action -onerror general_failure
- -action -ftp rename handle temp/foo/test_file.dat temp/foo/test_file.bak
-
- # DEBUG
- #-action -popup Was temp/foo/test_file.dat renamed to temp/foo/test_file.bak?
- #-action -print lastline: %FTP.LASTLINE%
-
- # TEST FOR test_file.bak ON REMOTE SERVER
- -action -print testing for test-file.bak on remote ftp server
- -action -set OPERATION=test3
- -action -onerror general_failure
- -action -ftp test handle temp/foo/test_file.bak
-
- # DEBUG
- #-action -print lastline: %FTP.LASTLINE%
-
- # RENAME "test-file" ON REMOTE SERVER
- -action -print rename the test-file on remote ftp server
- -action -set OPERATION=rename
- -action -onerror general_failure
- -action -ftp rename handle temp/foo/test_file.bak temp/foo/test_file.dat
-
- # DEBUG
- #-action -print lastline: %FTP.LASTLINE%
-
- # RGET/MGET
- -action -print test recursive get from remote ftp server
- -action -set OPERATION=rget/mget
- -action -onerror general_failure
- -action -ftp rget handle temp/foo/* %LOCAL_DIR% 0
-
- # DEBUG
- #-action -print lastline: %FTP.LASTLINE%
-
- # RDELETE
- -action -print test recursive delete from remote ftp server
- -action -set OPERATION=rdelete
- -action -onerror general_failure
- -action -ftp rdel handle temp/foo/*
-
- # DEBUG
- #-action -popup has temp/foo/* been cleared?
- #-action -print lastline: %FTP.LASTLINE%
-
- # RPUT/MPUT
- -action -print test recursive put to remote ftp server
- -action -set OPERATION=rput/mput
- -action -onerror general_failure
- -action -ftp rput handle %LOCAL_DIR%\* temp/foo 0
-
- # DEBUG
- #-action -popup has temp/foo/* been restored?
- #-action -print lastline: %FTP.LASTLINE%
-
- # TEST FOR "test-file" ON REMOTE SERVER
- -action -print testing for "test-file" on remote ftp server
- -action -set OPERATION=test4
- -action -onerror general_failure
- -action -ftp test handle temp/foo/test_file.dat
-
- # DEBUG
- #-action -print lastline: %FTP.LASTLINE%
-
- # CLOSE FTP CONNECTION
- -action -print closing ftp connection
- -action -ftp close handle
-
- # DEBUG
- #-action -print lastline: %FTP.LASTLINE%
-
- -action -print done!
- }
-
- # connection failed
- {
- -name connect_fail
- -action -print FTP open connection failed with error:
- -action -print %FTP.ERROR%
- -action -return abort
- }
-
- # general failed
- {
- -name general_failure
- -action -print FTP %OPERATION% failed with error:
- -action -print %TG.LAST_ERROR%
- -action -print Closing connection.
- -action -ftp close handle
- -action -return abort
- }
-
-